// metrics/metrics.go
package metrics

import (
	"github.com/prometheus/client_golang/prometheus"
)

// AlertSentCounter 告警发送总数
var AlertSentCounter = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "diting_alert_sent_total",
		Help: "Total number of alerts sent by platform and status",
	},
	[]string{"platform", "status"},
)

//自监控
var (
	// ServiceHealthy 服务健康状态 (1=健康, 0=异常)
	ServiceHealthy = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Name: "diting_self_healthy",
			Help: "Health status of the Odysseus_DiTing service (1=healthy, 0=unhealthy)",
		},
	)

	// LastAlertSentTimestamp 最后一次成功发送告警的时间戳
	LastAlertSentTimestamp = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Name: "diting_last_alert_sent_timestamp_seconds",
			Help: "Unix timestamp of the last successfully sent alert",
		},
	)

	// ConfigReloadTimestamp 配置文件加载时间戳
	// ConfigReloadTimestamp = prometheus.NewGauge(
	// 	prometheus.GaugeOpts{
	// 		Name: "diting_config_reload_timestamp_seconds",
	// 		Help: "Unix timestamp of the last config reload",
	// 	},
	// )
)


// // AlertSendDuration 告警发送耗时
// var AlertSendDuration = prometheus.NewHistogramVec(
// 	prometheus.HistogramOpts{
// 		Name:    "diting_alert_send_duration_seconds",
// 		Help:    "Histogram of alert send duration by platform",
// 		Buckets: prometheus.DefBuckets,
// 	},
// 	[]string{"platform"},
// )

// // RequestDuration HTTP 请求耗时
// var RequestDuration = prometheus.NewHistogramVec(
// 	prometheus.HistogramOpts{
// 		Name:    "diting_request_duration_seconds",
// 		Help:    "HTTP request duration in seconds",
// 		Buckets: prometheus.DefBuckets,
// 	},
// 	[]string{"method", "path", "status"},
// )

func init() {
	prometheus.MustRegister(AlertSentCounter)
	// prometheus.MustRegister(AlertSendDuration)
	// prometheus.MustRegister(RequestDuration)
	prometheus.MustRegister(ServiceHealthy)
	prometheus.MustRegister(LastAlertSentTimestamp)
	// prometheus.MustRegister(ConfigReloadTimestamp)
	ServiceHealthy.Set(1)
}